/**
 * Created by hongye.liu on 14-10-27.
 */
define(
    [
      'underscore'
      ,'jquery'
      ,'backbone'
      ,'jqueryMobile'
      ,'../module/busApp/busApp'
      ,'../module/busApp/busChange/busChange'
      ,'../module/busApp/busLine/busLine'
      ,'../module/busApp/busNearby/busNearby'
      ,'../module/busApp/busSearch/busSearch'
      ,'../module/busApp/sideContent/sideContent'
      , '../module/busApp/busRemind/busRemind'
      ,'../module/busApp/busSiteAdd/busSiteAdd'
      ,'../module/busApp/cityContent/cityContent'
      ,'../module/busApp/busMap/busMap'
    ],
    function(_,$,backbone,jqm,busApp,busChange,busLine,busNearby,busSearch,sideContent,busRemind,busSiteAdd,cityContent,busMap,global){
        var router = backbone.Router.extend({
            routes:{
                '':'busCommand',
//                'module/:busChangePart':'moduleCommand',
                'busChangePart':'busChangeCommand',
                'busLinePart':'busLineCommand',
                'busNearbyPart':'busNearbyCommand',
                'sideHandlePart':'sideHandle',
                'busRemind':'busRemindCommand',
                'busSiteAdd':'busSiteAddCommand',
                'cityContent':'cityContentCommand',
                'busMap':'busMapCommand',
                'busSearchResult':'busSearchResultCommand',
                '*error':"errorHandle"
            },

            /**
             * 初始化路由时提示用户开启GPS导航
             */
//             initialize:function(){
////                $("body").delay(5000).show();  //延迟5秒来现在id为test的div
//
//                if(typeof cordova !== "undefined") {
//                    function locPlugin() {
//                        this._callback;
//                    }
//                    locPlugin.prototype.location = function(cb) {//插件的location方法
//                        this._callback = cb;
//                        //exec的参数依次是  回调函数， 执行失败的回调函数， xml中注册的插件名， 插件中用于判断的Action名， 参数
//                        return cordova.exec(cb, null, 'BdLocationDemo', "location", []);
//                    };
//                    cordova.addConstructor(function() {
//                        if (!window.plugins) {
//                            window.plugins = {};
//                        }
//                        window.plugins.locPlugin = new locPlugin();  //addPlugin方法取消后用这种方式创建插件
//                    });
//                }
//                window.plugins.locPlugin.location(function(data){
//                    global.longitude = data.Longitude;
//                    global.latitude = data.Latitude;
//                });
//             },

            busMapCommand:function(){
                var busMapView = new busMap();
            },
            busSiteAddCommand:function(){
                var busSiteAddView = new busSiteAdd();
            },
            busRemindCommand:function(){
                var busRemindView = new busRemind();
            },
            sideHandle:function(){
                var sideContentView = new sideContent();
            },
            busChangeCommand:function(){
                var busChangeView = new busChange();
            },
            busLineCommand:function(){
                var busLineView = new busLine();
            },
            busNearbyCommand:function(){
                var busNearbyView = new busNearby();
            },
            cityContentCommand:function(){
                var cityContentView = new cityContent();
            },
//            errorHandle:function(){
//              alert("找不到页面");
//            },
            busCommand:function(){
                this.changePage(new busApp());
            },
            changePage:function (page) {
                 new busApp();
                 new busChange();
                 new busMap();
            }
        })
        return router;
    }

)
